<!DOCTYPE html>
<html>
<head>
    <title>备件需求计划详情关联</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <table id="jqGrid"></table>
    </div>
</div>

<script>
    // 只拉取终版需求计划中的备件需求明细
    var sparePartCode = getQueryString("sparePartCode");
    $(function () {
        $("#jqGrid").Grid({
            url: '../sparepartrequdetail/list?planType=RESULT&isCancelTransit=0&materialCode=' + sparePartCode,
            colModel: [
                {label: '计划编码', name: 'businessCode', index: 'BUSINESS_CODE', width: 120},
                {label: '申请单位', name: 'applyUnit', index: 'APPLY_UNIT', width: 80},
                {label: '备件名称', name: 'materialName', index: 'MATEROA:_NAME', width: 120},
                {label: '备件规格', name: 'spec', index: 'SPEC', width: 120},
                {label: '需求数', name: 'demandNum', index: 'DEMAND_NUM', width: 80},
                {label: '已入库数', name: 'inboundNum', index: 'INBOUND_NUM', width: 80},
                {label: '在途数', name: 'transitNum', index: 'TRANSIT_NUM', width: 80},
                {name: 'planPrice', hidden: true},
                {name: 'isCancelTransit', hidden: true},
                {name: 'remark', hidden: true},
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
                {label: 'cjCode', name: 'cjCode', index: 'CG_CODE', hidden: true}
            ]
        });
    });

    let vm = new Vue({
        el: '#rrapp',
        data: {
            q: {
                partName: '', // 备件名称
                spec: '', // 备件规格
                partCode: '', // 备件编码
                erpCode: '', // ERP编码
                producor:'', // 供应厂家
            }
        },
        methods: {
            query: function () {
                vm.reload();
            },
            reload: function (event) {
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: vm.q,
                    page: page
                }).trigger("reloadGrid");
            },
            reloadSearch: function () {
                vm.q = {
                    name: '', // 备件名称
                    spec: '', // 备件规格
                    partCode: '', // 备件编码
                    erpCode: '', // ERP编码
                    producor:'', // 供应厂家
                };
                vm.reload();
            }
        }
    });
    var getSparePart = function () {
        let data = getSelectedRowData("#jqGrid");
        if(data.isCancelTransit === '1' || data.transitNum === '0'){
            iview.Message.error("请选择在途数大于0的需求明细记录！");
            return
        }
        return data;
    }
</script>
</body>
</html>
